<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="get">get</button>
    <button class="post">post</button>
</body>
<script>
    var getBtn = document.querySelector(".get");
    var postBtn = document.querySelector(".post");

    getBtn.onclick = function () {

        var wd = ""; // 搜索关键词(默认查询所有)
        var col = "id";// 排序列名(默认按编号排序)
        var type = "asc"; // 排序方式(默认升序   desc:降序)
        var page = 1;  // 展示的页面(默认第一页)
        var size = 5;  // 每页展示多少条 

        var xhr = new XMLHttpRequest();

        xhr.open("get", `http://121.43.116.41/demo/php/searchGradeOrderLimit.php?wd=${wd}&col=${col}&type=${type}&page=${page}&size=${size}`, true);

        xhr.send();

        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200) {
                var result = xhr.responseText;

                // 数据处理
                result = JSON.parse(result);
                console.log(result);

                // 动态生成

            }
        }


    }

    postBtn.onclick = function () {
        var account = "a123123";
        var pwd = "123123"

        var xhr = new XMLHttpRequest();

        xhr.open("post", "http://121.43.116.41/demo/php/login_account.php", true);

        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xhr.send(`account=${account}&pwd=${pwd}`);

        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200) {
                var result = xhr.responseText;

                // 数据处理
                result = JSON.parse(result);
                console.log(result);


                // 判断  


            }
        }
    }


</script>

</html>